<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/fuman/js/purchase.js" ></script>
<script language="javascript">
  function onstsubmit()
	{
		$('#expressform').modal('hide');	
		$('#attributeform').submit();
	}
  function atmangbanedit()
  {
    var tborder = $("input[id='tborder']").val();
    if(!tborder){
      alert("采购编号不能为空");return false;
    }
    var kdnumber=$("input[id='kdnumber']").val();
    if(!kdnumber){
      alert("快递单号不能为空");return false;
    }
    var kdname = $("input[id='kdname']").val();
    if(!kdname){
      alert("快递名称不能为空");return false;
    }
    $("#editsaveform").submit();
  }
</script>
<title>采购列表</title>
<body class="withvernav">
<div class="bodywrapper">
{{include file='/public/orderleft.tpl'}}
<div class="centercontent">
  <div class="pageheader notab">
    <h1 class="pagetitle">采购列表</h1>
    <span class="pagedesc">1、手动添加或者库存预警中添加采购单<br></span>
    
    <span class="pagedesc">2、线上采购，采购人员与供应商确认最终价格、是否免运费，确认完成后点击付款，等待商家发货有运单号后标采购完成，录入运单号！</span><br>
    <span class="pagedesc">3、线下采购，采购单准确无误即可点击确认采购按钮！支付情况视真实付款情况。<br></span>
  </div>
  <!--pageheader-->
  <div id="contentwrapper" class="contentwrapper">
    <div id="basicform" class="subcontent"> 
      <!--搜索栏-->
     <div style="float:left">
     <div style="padding:3px">
        <a href="javascript:void(0)" onClick="batchPaystatus()" class="stdbtn btn_red"><span>标付款</span></a>
        </div>
      </div>
      <div style="clear: both"></div>
      <div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
    </div>
    <form class="stdform stdform2" method="get" id="search" action="/purchase/purchaselist">
      <div class="tableoptions">
       
      
        
      申请时间
        <input type="text"  name="starttime" value="{{$starttime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" />
        -
        <input type="text"  name="endtime" value="{{$endtime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" />
       
       &nbsp;&nbsp; <select name="tys" id="tys" style="width:100px;" >
              <option value="">编号</option>
              <option value="1"  {{if $tys eq 1}}selected{{/if}}>淘宝运单号</option>
              <option value="2"  {{if $tys eq 2}}selected{{/if}}>采购单编号</option>
              <option value="3"  {{if $tys eq 3}}selected{{/if}}>淘宝订单号</option>
          </select>
       : <input type="text" name="kw" id="kw" class="width200" value="{{$kw}}" placeholder="运单号、工厂订单号、淘宝单号、订单编号" />
         商品编号: <input type="text" name="goodssku" id="goodssku" class="width100" value="{{$goodssku}}" placeholder="SKU" />
         商品标识: <input type="text" name="skucode" id="skucode" class="width100" value="{{$skucode}}" placeholder="唯一识别码" />
          采购人:
          <select name="buyer" id="buyer" class="selection select2_group" style="width:100px;" >
              <option value="">请选择</option>
              {{foreach from=$buyerlist item=res key=key}}
              <option value="{{$res}}"  {{if $res eq $buyer}}selected{{/if}}>{{$res}}</option>
              {{/foreach}}
          </select>
          供应商:
          <select name="supplier" id="supplier" class="selection select2_group" style="width:100px;" >
              <option value="">请选择</option>
              {{foreach from=$factorys item=res key=key}}
                 <option value="{{$res.id}}"  {{if $res.id eq $supplier}}selected{{/if}}>{{$res.name}}</option>
              {{/foreach}}
          </select>
          
           状态:
          <select name="status" id="status" class="selection select2_group" style="width:100px;" >
              <option value="">请选择</option>
                 <option value="1"  {{if $status==1}}selected{{/if}}>申请中</option>
                 <option value="2"  {{if $status==2}}selected{{/if}}>采购完成</option>
                 <option value="3"  {{if $status==3}}selected{{/if}}>质检完成</option>
          </select>
           支付状态:
        <select name="ispay" id="ispay" class="selection select2_group" style="width:100px;" >
              <option value="">请选择</option>
                 <option value="1"  {{if $ispay==1}}selected{{/if}}>未支付</option>
                 <option value="2"  {{if $ispay==2}}selected{{/if}}>已支付</option>
          </select>
          <button class="btn btn-primary" id="searchbtn">Search</button>
      </div>
    </form>
    <!--搜索栏结束-->
    <table cellpadding="0" cellspacing="0" border="0" class="stdtable" style="table-layout: fixed;">
      <thead>
        <tr class="lbbt">
          <td width="3%"  bgcolor="#FEFFF1"><a onClick="allSelect('ppid[]')">全选</a></td>
          <td width="8%" bgcolor="#FEFFF1">订单编号</td>
          <td  bgcolor="#FEFFF1" width="10%">商品SKU</td>
          <td  bgcolor="#FEFFF1">预计入库时间</td>
          <td  width="5%"  bgcolor="#FEFFF1">采购人</td>
          <td width="5%"  bgcolor="#FEFFF1">供应商</td>
          <td  bgcolor="#FEFFF1">采购总价</td>
          <td  bgcolor="#FEFFF1">状态</td>
           <td  bgcolor="#FEFFF1">申请时间</td>
          <td  bgcolor="#FEFFF1">支付情况</td>
         
          <td width="15%"  bgcolor="#FEFFF1" >操作</td>
        </tr>
      </thead>
      <tbody >
      
      {{foreach from=$orderlist item=li key=key}}
      <tr>
        <td style="background-color:{{$li.colors}}"><input name="ppid[]" type="checkbox" class="none" id="ppid[]" value="{{$li.id}}" /></td>
        <td valign="middle" style="position:relative;"><a href="/purchase/ordermod?id={{$li.id}}&t=show" target="_blank"><font color="#6666FF">{{$li.orderstockid}}</font></a></td>
        <td valign="middle">{{$li.goods_no}}</td>
        <td valign="middle">{{$li.waittime}}</td>
        <td valign="middle">{{$li.createuser}}</td>
        <td style="position:relative;">{{$factory[$li['made_factory']]}}</td>
        <td style="position:relative;">{{$li.allmoney}}</td>
        <td valign="middle">
         {{if $li.chkflag ==0}}
             {{if $li.status==1}}申请中{{/if}}
             {{if $li.status==2}}采购完成{{/if}}
         {{else}}
         	质检完成
         {{/if}}
		 {{if $li.made_factory eq 4 or $li.made_factory eq 5}}
         	<br><span style="font-size:12px;">生产进度:{{$made_status[$li['made_status']]}}</span>
         {{/if}}
        </td>
         <td class="cz">{{$li.opertime}}</td>
        <td valign="middle">
         {{if $li.ps==0}}
          <input type="hidden" id="spduser{{$li.id}}" value="0" />
          <input type='button' value='请求付款' id='getuserbtn{{$li.id}}' onClick="savegetpay({{$li.id}})">
        {{/if}}
        
         {{if $li.ps==1}}
          <input type="hidden" id="spduser{{$li.id}}" value="0" />
          <input type='button' value='{{if $li.ps == 2}}已付{{else}}未付款{{/if}}' id='getuserbtn{{$li.id}}' onClick="savegetuser('{{$li.id}}','{{if $li.ps ==2}}N{{else}}Y{{/if}}')">
          {{/if}}
          
           {{if $li.ps==2}}
         <input type="hidden" id="spduser{{$li.id}}" value="{{if $li.ps ==2}}1{{else}}0{{/if}}" />
       <span onClick="savegetuser('{{$li.id}}','{{if $li.ps ==2}}N{{else}}Y{{/if}}')"> 已支付 </span> {{if $managers && $li.status==1}}
       <input type='button' style="display:none" value='{{if $li.ps == 2}}取消支付{{else}}未付{{/if}}' id='getuserbtn{{$li.id}}' onClick="savegetuser('{{$li.id}}','{{if $li.ps ==2}}N{{else}}Y{{/if}}')">{{/if}}
          {{/if}}
          
           </td>
       
        <td class="cz">
        <!-- {{if $li.ps==2 && $li.status==1}}
           <span id=sbubtom{{$li.sid}}> 
           <a href="javascript:void(0)" onClick="showsavebuy('{{$li.id}}','24')"><img src="/fuman/images/cgwc.jpg" style="cursor:pointer"></span>
        	 <a href="/purchase/ordermod?id={{$li.id}}"> <img src="/fuman/images/edits.png" /></a>
         {{else}}
          <span>
          {{if $li.status == 1 && $li.ps !=2}}
          <a href="/purchase/ordermod?id={{$li.id}}"> <img src="/fuman/images/edits.png" /></a>
          <a href="javascript:void(0)" onClick="delstocklist({{$li.id}})"><img src="/fuman/images/trash.png" width="15" height="16" /> 删除</a>
          {{else}}
           <span>
           {{if $li.chkflag ==0}}
          <a href="javascript:void(0)" onClick="editsavebuy('{{$li.id}}','24')"><img src="/fuman/images/edits.png" /></a>
            </span>
            {{/if}}
          {{/if}}</span>
          
          {{/if}}
          
          <span>
          
          <a href="/purchase/ordermod?id={{$li.id}}&t=show" target="_blank"><img src="/fuman/images/ckk.png" /></a></span>-->
         
         <!--外采购必须要已支付才能显示采购完成-->
         {{if $li.made_factory==3}}
            	{{if $li.ps==1 && $li.status==1}}
                	<!--外采购等待支付-->
                	<a href="/purchase/ordermod?id={{$li.id}}">编辑</a> &nbsp;| &nbsp;<a href="javascript:void(0)" onClick="delstocklist({{$li.id}})"> 删除</a> &nbsp;|&nbsp;  <a href="/purchase/ordermod?id={{$li.id}}&t=show" target="_blank">查看</a>
                {{/if}}
                
                {{if $li.ps==2 && $li.status==1}}
                	<!--外采购已支付状态-->
                	<a href="javascript:void(0)" onClick="showsavebuy('{{$li.id}}','24')"> 采购完成 </a>&nbsp;|&nbsp; 
        	 <a href="/purchase/ordermod?id={{$li.id}}"> 编辑 </a>&nbsp;|&nbsp;  <a href="/purchase/ordermod?id={{$li.id}}&t=show" target="_blank">查看</a>
                {{/if}}
                
                {{if $li.chkflag ==0 && $li.ps==2 && $li.status==2}}
         		 <a href="javascript:void(0)" onClick="editsavebuy('{{$li.id}}','24')">编辑运单号</a> &nbsp;|&nbsp;  <a href="/purchase/ordermod?id={{$li.id}}&t=show" target="_blank">查看</a>
                {{/if}}
            	
         {{/if}}
         
         
         {{if $li.made_factory !=3}}
         
         
         		{{if  $li.status==1}}
                	<!--除外采购外，其他的可以不标已支付-->
                	<a href="javascript:void(0)" onClick="showsavebuy('{{$li.id}}','24')"> 确认采购 </a>&nbsp;|&nbsp;<a href="/purchase/ordermod?id={{$li.id}}">编辑</a> &nbsp;| &nbsp;<a href="javascript:void(0)" onClick="delstocklist({{$li.id}})"> 删除</a> &nbsp;|&nbsp;  <a href="/purchase/ordermod?id={{$li.id}}&t=show" target="_blank">查看</a>
                {{/if}}
                
                {{if $li.chkflag ==0 && $li.status==2}}
         		 <a href="javascript:void(0)" onClick="editsavebuy('{{$li.id}}','24')">编辑运单号</a> &nbsp;|&nbsp;  <a href="/purchase/ordermod?id={{$li.id}}&t=show" target="_blank">查看</a>&nbsp;| &nbsp;<a href="javascript:void(0)" onClick="delstocklist({{$li.id}})"> 删除</a>
                {{/if}}
                
                
            
            
         {{/if}}
			
           		 {{if $li.chkflag ==1}}
         		<a href="/purchase/ordermod?id={{$li.id}}&t=show" target="_blank">查看</a>
                {{/if}}
        </td>
      </tr>
      {{/foreach}}
        </tbody>
      
    </table>
    <div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
  </div>
</div>

<!-- 模态框（Modal）显示填写货运号 -->
  <form  method="post" name="saveform" id="saveform" action="/purchase/ajaxbutton?op=savekd">
  <input type="hidden" name="orderid" id="orderid">
  <div class="modal fade" id="showmabangorder" tabindex="-1" role="dialog" aria-labelledby="sshowmabangorder" aria-hidden="true">
    <div class="modal-dialog" style="width:50%;">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" 
               aria-hidden="true">× </button>
          <h4 class="modal-title" id="sshowmabangorder"> 请填写货运单号  </h4>
        </div>
        <div class="modal-body">
         <table width="100%" border="0" cellspacing="0" cellpadding="0">
            
          <tbody id="showmabangid"></tbody>
          </table>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" 
               data-dismiss="modal"> 关闭 </button>
            <button type="button" class="btn btn-primary"  onclick="atmangban()"> 提交 </button>
          </div>
        </div>
        <!-- /.modal-content --> 
      </div>
      <!-- /.modal-dialog --> 
    </div>
  </div>
  <!-- /.modal -->
  </form>

  <!-- 模态框（Modal）显示 编辑 采购编号 快递号等信息 -->
  <form  method="post" name="editsaveform" id="editsaveform" action="/purchase/ajaxbutton?op=editSave">
    <input type="hidden" name="purchaselist_id" id="purchaselist_id">
    <div class="modal fade" id="editmabangorder" tabindex="-1" role="dialog" aria-labelledby="sshowmabangorder" aria-hidden="true">
      <div class="modal-dialog" style="width:50%;">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal"
                    aria-hidden="true">× </button>
            <h4 class="modal-title" id="seditmabangorder"> 请编辑采购编号与快递单号  </h4>
          </div>
          <div class="modal-body">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tbody id="editmabangid"></tbody>
            </table>
            <div class="modal-footer">
              <button type="button" class="btn btn-default"
                      data-dismiss="modal"> 关闭 </button>
              <button type="button" class="btn btn-primary"  onclick="atmangbanedit()"> 提交 </button>
            </div>
          </div>
          <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
      </div>
    </div>
    <!-- /.modal -->
  </form>

</body>
</html>